#include "PassBallToNormalPassPositionBehaviour.h"


/*
 * Normalne prihravanie na bod vypocitany funkciou CalculateNormalPassPosition
 *
 */
void PassBallToNormalPassPositionBehaviour::Behave()
{
	Point myPosition = world->me->pos;
	Point passPosition((float)DATA_STORAGE.lfTmpX, (float)DATA_STORAGE.lfTmpY);
	DBGN("Prihravka na (%.3lf, %.3lf)", passPosition.GetX(), passPosition.GetY());
				
	Vector vectFromMeToPassPoint = passPosition - myPosition;
	float lfDistance = vectFromMeToPassPoint.GetLength();
	float lfPassSpeed = (lfDistance - (float)lfMinPassDistance) / ((float)lfMaxPassDistance - (float)lfMinPassDistance) 
					* (world->params->server->ball_speed_max - 1.9f) +  1.9f;
				
	/*
	ofstream out("Normalne prihravanie.txt", ios::app); // Zapis do suboru
	int nSimTime = world->state->GetSimTime();
	int nPlayerNumber = world->me->GetUniform();
	out << "[" << nSimTime << "]" << " Hrac c." << nPlayerNumber << endl;
	out.close();
	*/
	GetPassBallToBehaviour()->Behave(passPosition, GetPassBallToBehaviour()->CorrectPassSpeed(lfPassSpeed));
}
